<?php
/**
 * Coelacanth_PrintNewPasswordCLIScript
 *
 * @copyright 2008-12-23, Robert Impey
 */

class
	Coelacanth_PrintNewPasswordCLIScript
extends
	CLIScripts_CLIScript
{
	public function
		do_actions()
	{
		$new_password
			= Security_PasswordsHelper::make_password(
				$this->get_length()
			);

        echo $new_password . PHP_EOL;
	}
	
	/**
	 * Allows the user to set the number of characters in the password.
	 *
	 * e.g. ./Coelacanth_PrintNewPasswordCLIScript.php --length=20
	 *
	 * @return int The length of the password.
	 */
	private function
		get_length()
	{
		if ($this->has_arg('length')) {
			return $this->get_arg('length');
		} else {
			return $this->get_default_length();
		}
	}
	
	/**
	 * Should this number be retrieved from a configuration file?
	 * 
	 * @return int The default length for a password.
	 */
	private function
		get_default_length()
	{
		return 8;
	}
}
?>